package com.feihao.controller;

import com.feihao.domian.AccountEvent;
import com.feihao.domian.Response;
import com.feihao.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.UUID;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @GetMapping("/transfer")
    public Response transfer(String accountNoA, String accountNoB, Double amount) throws Exception {
        String tx_no= UUID.randomUUID().toString();
        AccountEvent ace = new AccountEvent(accountNoA,accountNoB,amount,tx_no);


        accountService.sendUpdateAccountBalance(ace);
        return Response.success();
    }
}
